//
//  ViewController.m
//  yuanjiang
//
//  Created by YuanJiang on 2019/9/19.
//  Copyright © 2019 llbt. All rights reserved.
//

#import "ViewController.h"
#import "OneVC.h"
#import "TwoVC.h"
#import "ThreeVC.h"
#import "FourVC.h"
#import "FiveVC.h"
#import "SixVC.h"
#import "SevenVC.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong) UITableView *tableView;

@property(nonatomic,strong) NSMutableArray *array;

@property(nonatomic,strong) NSArray *MethodArray;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initData];
    self.tableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    self.tableView.delegate =self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
}

-(void)initData
{
    if (!self.MethodArray) {
        self.MethodArray = @[@"OneVC",
                             @"TwoVC",
                             @"ThreeVC",
                             @"FourVC",
                             @"FiveVC",
                             @"SixVC",
                             @"SevenVC"];
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"cellid";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.textLabel.text= self.array[indexPath.row];
    return cell;
}

-(NSMutableArray *)array
{
    if (!_array) {
        _array = [NSMutableArray arrayWithObjects:@"动态给分类添加属性",
                  @"方法的交换swizzing",
                  @"字典转模型",
                  @"获取所有的私有属性和方法",
                  @"对私有属性的修改",
                  @"归档解档",
                  @"动态添加放法",
                  nil];
    }
    return _array;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   UIViewController *vc = [[NSClassFromString(self.MethodArray[indexPath.row]) alloc] init];
    vc.title = self.array[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
